package random.fox.p2p.ui;

import android.content.Context;
import android.support.v7.widget.Toolbar;
import android.util.AttributeSet;
import android.view.View;
import android.widget.GridView;
import android.widget.LinearLayout;

import javax.inject.Inject;

import butterknife.ButterKnife;
import butterknife.InjectView;
import de.greenrobot.event.EventBus;
import random.fox.p2p.App;
import random.fox.p2p.R;
import random.fox.p2p.event.ActionBarEvent;
import random.fox.p2p.model.UserInfoModule;
import random.fox.p2p.pathview.Utils;
import random.fox.p2p.presenter.UserInfoPresenter;
import random.fox.p2p.util.Constants;
import random.fox.p2p.view.IUserInfoView;

/**
 * Created by acer on 2015/3/22.
 */
public class ExpandPersonalitysView extends LinearLayout implements IUserInfoView {

    @Inject
    UserInfoPresenter userInfoPresenter;

    @InjectView(R.id.toolbar)
    Toolbar toolbar;
    @InjectView(R.id.expand_personality_grid_view)
    GridView gridView;

    public ExpandPersonalitysView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        ButterKnife.inject(this);
        ((App) getContext().getApplicationContext()).createScopedGraph(new UserInfoModule(this)).inject(this);
        Utils.waitForMeasure(this, new Utils.OnMeasuredCallback() {
            @Override
            public void onMeasured(View view, int width, int height) {
//               LinearLayout itemLinearLayout = (LinearLayout) View.inflate(getContext(), R.layout.personality_item, null);
//                itemLinearLayout.measure(0,0);
//                int itemHeight = itemLinearLayout.getMeasuredHeight();
                userInfoPresenter.loadData(gridView, width, height, Constants.TYPE.EXPAND_PERSONALITY);
            }
        });
        toolbar.setTitle("*的标签");
        EventBus.getDefault().post(new ActionBarEvent(toolbar, -1, true));
    }


    @Override
    public void showProgress() {

    }

    @Override
    public void hideProgress() {

    }

    @Override
    public void showMessage(String message) {

    }

    @Override
    public void fillData(String age, String city, String school) {
        //不用实现
    }
}
